const axios = require('axios')
axios.defaults.baseURL='http://192.168.56.100:8080/zentao';
axios.defaults.headers={'Content-Type': 'application/json','Token':'501ee3223457921a10f8efb7f75d1bcb'}


// 配置一些基本参数
//获取token
async function gettoken(){

await  axios.post('/api.php/v1/tokens',
{"account": "admin", "password": "xxxx"}).then(

    res=>{
        
        console.log(res.data);
    }
).catch(
    error=>{
        console.log(error)
    }
)


}

//获取自己的用户数据
async function getuser(){
// axios.get('/api.php/v1/user',{headers:{'Content-Type': 'application/json','Token':'501ee3223457921a10f8efb7f75d1bcb'}}).then(

await axios.get('/api.php/v1/user').then(

   // 获取返回数据
   res=>{

        console.log(res.data)
        
        }

).catch(
    error=>{
        console.log(error.response.data);
    }
)

}


//获取全部用户数据
async function getusers(){
// axios.get('/api.php/v1/user',{headers:{'Content-Type': 'application/json','Token':'501ee3223457921a10f8efb7f75d1bcb'}}).then(

await axios.get('/api.php/v1/users').then(

   // 获取返回数据
   res=>{

        console.log(res.data)
        
        }

).catch(
    error=>{
        console.log(error.response.data);
    }
)

}



//添加用户
async function addusers(){
// axios.get('/api.php/v1/user',{headers:{'Content-Type': 'application/json','Token':'501ee3223457921a10f8efb7f75d1bcb'}}).then(

await axios.post('/api.php/v1/users',{"account": "sq", "password": "Test123","realname":"sq","gender":"m"}).then(

   // 获取返回数据
   res=>{

        console.log(res.data)
        
        }

).catch(
    error=>{
        console.log(error.response.data);
    }
)

}


// console.log(gettoken())

// console.log(getuser())
// console.log(getusers())

console.log(addusers())

